#@layoutT("客户管理")
#define main()
	#@formStart()
		#@queryStart('名称')
		   <input type="search" name="xName" autocomplete="off" class="layui-input" placeholder="名称"/>
		#@queryEnd()
	#@formEnd()
	
	 	<div class='layui-row f-index-toolbar'>
		<div class='layui-col-xs12'>
			<div class="layui-btn-group">
				<button id='addBtn_' class="layui-btn layui-btn-normal layui-btn-sm">
				  <i class="layui-icon">&#xe608;</i> 新增
				</button>
				<button id='refreshBtn_' class="layui-btn layui-btn-normal layui-btn-sm">
				  <i class="layui-icon">&#xe669;</i> 刷新
				</button>			
				<button id='deleteBtn_' class="layui-btn  layui-btn-normal layui-btn-sm">
				  <i class="layui-icon">&#xe640;</i> 删除
				</button>		
			</div>
		</div>
	</div>
	<div class="layui-row  f-index-toolbar">
			<div class="layui-col-xs12">
   				<table id="maingrid" lay-filter="maingrid"></table>
   			</div>
   	</div>
   	
   	<!-- 	每行的操作按钮 -->
	<script type="text/html" id="bar_maingrid">
  		<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
		<a class="layui-btn layui-btn-xs" lay-event="role">任务</a>
		<a class="layui-btn layui-btn-xs" lay-event="contact">联系人</a>
  		<a class="layui-btn layui-btn-xs layui-btn-danger lay-event="del">删除</a>
	</script>
#end

#define js()
<!-- 分页表格 -->
<script>
	
	 function userRole(obj){
		var data=obj.data;
		var rCustID = data.sID;
		var url='#(path)/portal/dbm/customer/schedule/' + rCustID;
		openDialog("任务",url,false,null,null);
	 }
	 
	 function listContact(obj){
		var data=obj.data;
		var rCustID = data.sID;
		var url='#(path)/portal/dbm/customer/contact/' + rCustID;
		openDialog("联系人",url,false,null,null);
	 }
	

	gridArgs.title='客户';
	gridArgs.dataId='sID';
	gridArgs.deleteUrl='#(path)/portal/dbm/customer/delete';
	gridArgs.updateUrl='#(path)/portal/dbm/customer/edit/';
	gridArgs.addUrl='#(path)/portal/dbm/customer/add';
	//gridArgsoletUrl='#(path)/portal/dbm/customer/schedule';
	gridArgs.gridDivId ='maingrid';
	initGrid({id : 'maingrid'
			,elem : '#maingrid'
			,cellMinWidth: 80
			,cols : [ [
					{title: '主键',field : 'sID',width : 35,checkbox : true},						
					//{title:'序号',type:'numbers',width:35},
					{title: '名称', field: 'xName',width:120 },
        			{title: '密钥', field: 'xKey',width:280,templet:function(d){
        		        return d.xKey.replace(/</g, "&lt;").replace(/>/g, "&gt;");
        		      }
					},
					{title: '任务', field: 'xSchedule',width:150},
	        		//{title: '启用功能', field: 'xIsFunc',width:100,templet:'#isfunc'},
	        		//{title: '启用心跳', field: 'xIsHeartbeat',width:100,templet:'#isheartbeat'},
	        		//{title: '1手动', field: 'xIsInterval1',width:80,templet:'#isinterval1'},
	        		//{title: '2每月', field: 'xIsInterval2',width:80,templet:'#isinterval2'},
	        		//{title: '3每周', field: 'xIsInterval3',width:80,templet:'#isinterval3'},
	        		{title: '4每天', field: 'xIsInterval4',width:80,templet:'#isinterval4'},
	        		{title: '5每小时', field: 'xIsInterval5',width:80,templet:'#isinterval5'},
	        		{title: '6每10分钟', field: 'xIsInterval6',width:100,templet:'#isinterval6'},
	        		{title: '7每5分钟', field: 'xIsInterval7',width:100,templet:'#isinterval7'},
	        		{title: '8每分钟', field: 'xIsInterval8',width:80,templet:'#isinterval8'},
	        		{title: '9系统启动时', field: 'xIsInterval9',width:120,templet:'#isinterval9'},
	        		{title: '心跳间隔', field: 'xHeartbeatInterval',width:100,templet:function(d){return d.xHeartbeatInterval / 1000 + "s"}},
	        		{title: '心跳超时', field: 'xHeartbeatOuttime',width:100,templet:function(d){return d.xHeartbeatOuttime / 1000 + "s"}},
	        		{title: '创建时间', field: 'sCreateTime',width:180},
	        		{title: '最后修改', field: 'sLastUpdate',width:180},
	        		{title: '版本', field: 'sVersion',width:80},
	        		//{title: '性别', field: 'sex',templet:'#sexStr'},				
					{title: '操作',fixed:'right',width : 240,align : 'left',toolbar : '#bar_maingrid'} // 这里的toolbar值是模板元素的选择器
			] ]
			,url:"#(path)/portal/dbm/customer/list"
			,searchForm : 'searchForm'
		},{role:userRole,contact:listContact});
	
</script>

<script type="text/html" id="isfunc">
	<input type="checkbox" name="isfunc" value="{{d.sID}}" lay-skin="switch" lay-text="启用|关闭" {{ d.xIsFunc == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isheartbeat">
    <input type="checkbox" name="isheartbeat" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsHeartbeat == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval1">
    <input type="checkbox" name="isinterval1" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval1 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval2">
    <input type="checkbox" name="isinterval2" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval2 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval3">
    <input type="checkbox" name="isinterval3" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval3 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval4">
    <input type="checkbox" name="isinterval4" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval4 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval5">
    <input type="checkbox" name="isinterval5" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval5 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval6">
    <input type="checkbox" name="isinterval6" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval6 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval7">
    <input type="checkbox" name="isinterval7" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval7 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval8">
    <input type="checkbox" name="isinterval8" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval8 == 1 ? 'checked' : '' }}>               
</script>
<script type="text/html" id="isinterval9">
    <input type="checkbox" name="isinterval9" value="{{d.sID}}"lay-skin="switch" lay-text="启用|关闭" {{ d.xIsInterval9 == 1 ? 'checked' : '' }}>               
</script>
#end


 
 
 